package org.acghub.mtdb.common.type.impl;

import org.acghub.mtdb.common.Visitor;
import org.acghub.mtdb.common.type.TypeBasePrimitives;

import java.util.function.Function;

/**
 * @author zhouhe
 */
public class TypeBoolean extends TypeBasePrimitives {
    public TypeBoolean() {
        super("boolean");
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit(this);
    }

    @Override
    protected Function<String, Object> checkDefaultValueFunc() {
        return (value) -> {
            if ("true".equals(value)) {
                return true;
            }
            if ("false".equals(value)) {
                return false;
            }
            return null;
        };
    }

    @Override
    public String getDefaultValue() {
        return "false";
    }
}
